package org.teemor.demo.kafka.javaclient.consumer;

import com.alibaba.fastjson.JSON;
import jdk.nashorn.internal.parser.JSONParser;
import org.apache.kafka.clients.consumer.ConsumerInterceptor;
import org.apache.kafka.clients.consumer.ConsumerRecords;
import org.apache.kafka.clients.consumer.OffsetAndMetadata;
import org.apache.kafka.common.TopicPartition;

import java.util.Map;

/**
 * @Description:
 * @author zhoulk
 * @date: 2020/2/15
 */
public class SimpleInterceptor implements ConsumerInterceptor {

    @Override
    public ConsumerRecords onConsume(ConsumerRecords records) {
        System.out.println("拦截器被调用了");
        return records;
    }

    @Override
    public void close() {

    }

    @Override
    public void onCommit(Map offsets) {
        System.out.println("offset 提交了 start");
        System.out.println(JSON.toJSONString(offsets));
        System.out.println("offset 提交了  end");
    }

    @Override
    public void configure(Map<String, ?> configs) {

    }
}
